import { request } from "@/request";

export async function fetchList(data) {
  const res = await request("/admin/mallbook/pagingQuery", {
    method: "POST",
    data,
  });
  return {
    data: res?.data?.list,
    total: res?.data?.total,
    success: true,
  };
}

export async function fetchMallBookList(data) {
  return request("/admin/mallbook/listQuery", {
    method: "POST",
    data,
  });
}
export async function add(data) {
  return request("/admin/mallbook/detail/editing", {
    method: "POST",
    data,
  });
}

export async function update(data) {
  return request("/admin/mallbook/detail/editing", {
    method: "POST",
    data,
  });
}

export function remove(data) {
  return request(`/admin/mallbook/delete?ids=${data.ids}`, {
    method: "POST",
  });
}

export function fetchInfo(data) {
  return request(`/admin/mallbook/getDetailByKey/${data.id}`, {
    method: "POST",
  });
}

export function updateStatus(data) {
  return request(`/admin/mallbook/update`, {
    method: "POST",
    data,
  });
}
export function checkMallBooksRas(data) {
  return request(`/admin/mallBooksRas/check`, {
    method: "POST",
    data,
  });
}

export function addMallBooksRas(data) {
  return request(`/admin/mallBooksRas/add`, {
    method: "POST",
    data,
  });
}

export async function fetchMallBooksRasList(data) {
  const res = await request("/admin/mallBooksRas/pageQuery", {
    method: "POST",
    data,
  });
  return {
    data: res?.data?.list,
    total: res?.data?.total,
    success: true,
  };
}

export function removeMallBooksRas(data) {
  return request(`/admin/mallBooksRas/delete?ids=${data.ids}&specificationId=${data.specificationId}`, {
    method: "POST",
    data
  });
}

// 导入书籍
export function importBooksExcel(data) {
  return request(`/admin/mallbook/importBooksExcel`, {
    method: "POST",
    data,
  });
}
